- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
[Components] rosette_text_analytics #10937 #18441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
 | 
| WalkthroughAdds three new Rosette actions (extract entities, match names, translate name), extends the app with propDefinitions, HTTP helper methods and Rosette API wrappers (matchName, translateName, extractEntities, getLanguages), and updates package metadata (version and dependency). Changes
 Sequence Diagram(s)sequenceDiagram
  autonumber
  actor User
  participant Action as Action (Pipedream)
  participant App as Rosette App Client
  participant HTTP as _makeRequest
  participant API as Rosette API
  User->>Action: Trigger action with props
  Action->>App: Call method (matchName / translateName / extractEntities) with data
  App->>HTTP: Build request (base URL, headers, payload)
  HTTP->>API: POST /v1/... with X-RosetteAPI-Key
  API-->>HTTP: JSON response
  HTTP-->>App: Response
  App-->>Action: Response
  Action-->>User: Export $summary and return data
  note over App,HTTP: Header X-RosetteAPI-Key sourced from this.$auth.api_key
sequenceDiagram
  autonumber
  participant Action_E as Extract Entities
  participant App
  participant API as Rosette /v1/entities
  Action_E->>App: extractEntities({ content, options })
  App->>API: POST body { content, options{calculateConfidence, calculateSalience, includeDBpediaTypes} }
  API-->>App: entities[]
  App-->>Action_E: response
sequenceDiagram
  autonumber
  participant Action_M as Match Names
  participant App
  participant API as Rosette /v1/name-similarity
  Action_M->>App: matchName({ name1.text, name2.text })
  App->>API: POST body { name1, name2 }
  API-->>App: score
  App-->>Action_M: response
sequenceDiagram
  autonumber
  participant Action_T as Translate Name
  participant App
  participant API as Rosette /v1/name-translation
  Action_T->>App: translateName({ name, targetLanguage })
  App->>API: POST body { name, targetLanguage }
  API-->>App: translation, confidence
  App-->>Action_T: response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
 Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
 ✅ Passed checks (1 passed)
 ✨ Finishing touches🧪 Generate unit tests
 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
 🚧 Files skipped from review as they are similar to previous changes (1)
 ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (7)
components/rosette_text_analytics/actions/translate-name/translate-name.mjs (1)
7-7: Optional: Align component version metadata.
To reflect the package bump to 0.1.0, consider updating this action’s version to 0.1.0.- version: "0.0.1", + version: "0.1.0",components/rosette_text_analytics/actions/match-names/match-names.mjs (2)
36-36: Optional: Format score to two decimals in summary.
Improves readability without changing behavior.- $.export("$summary", "Successfully compared names, resulting in a score of " + response.score); + $.export("$summary", "Successfully compared names, resulting in a score of " + (typeof response.score === "number" ? response.score.toFixed(2) : response.score));
7-7: Optional: Align component version metadata.
To reflect the package bump to 0.1.0, consider updating this action’s version to 0.1.0.- version: "0.0.1", + version: "0.1.0",components/rosette_text_analytics/actions/extract-entities/extract-entities.mjs (2)
48-48: Guard against missing entities in summary.
Avoids runtime errors if the API returns no entities array.- $.export("$summary", "Successfully extracted " + response.entities.length + " entities"); + $.export("$summary", "Successfully extracted " + (Array.isArray(response?.entities) ? response.entities.length : 0) + " entities");
7-7: Optional: Align component version metadata.
To reflect the package bump to 0.1.0, consider updating this action’s version to 0.1.0.- version: "0.0.1", + version: "0.1.0",components/rosette_text_analytics/rosette_text_analytics.app.mjs (2)
26-33: Harden language options mapping (null-safety).
Prevents crashes if the API shape changes or is empty; you can enhance labeling later if the API returns display names.- async options() { - const response = await this.getLanguages(); - const languages = response.supportedLanguagePairs; - return languages.map(({ target }) => ({ - label: target.language, - value: target.language, - })); - }, + async options() { + const response = await this.getLanguages(); + const pairs = response?.supportedLanguagePairs ?? []; + return pairs.map(({ target = {} }) => ({ + label: target.language, + value: target.language, + })); + },
70-77: Set sane HTTP defaults (timeout, JSON headers).
Adds resiliency and explicit content negotiation.- return axios($, { - ...otherOpts, - url: this._baseUrl() + path, - headers: { - "X-RosetteAPI-Key": `${this.$auth.api_key}`, - ...headers, - }, - }); + return axios($, { + timeout: 30000, + ...otherOpts, + url: this._baseUrl() + path, + headers: { + "X-RosetteAPI-Key": `${this.$auth.api_key}`, + "Accept": "application/json", + "Content-Type": "application/json", + ...headers, + }, + });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
- components/rosette_text_analytics/actions/extract-entities/extract-entities.mjs(1 hunks)
- components/rosette_text_analytics/actions/match-names/match-names.mjs(1 hunks)
- components/rosette_text_analytics/actions/translate-name/translate-name.mjs(1 hunks)
- components/rosette_text_analytics/package.json(1 hunks)
- components/rosette_text_analytics/rosette_text_analytics.app.mjs(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
components/rosette_text_analytics/actions/translate-name/translate-name.mjs (2)
components/rosette_text_analytics/actions/extract-entities/extract-entities.mjs (1)
response(37-47)components/rosette_text_analytics/actions/match-names/match-names.mjs (1)
response(25-35)
components/rosette_text_analytics/actions/extract-entities/extract-entities.mjs (2)
components/rosette_text_analytics/actions/match-names/match-names.mjs (1)
response(25-35)components/rosette_text_analytics/actions/translate-name/translate-name.mjs (1)
response(25-31)
components/rosette_text_analytics/actions/match-names/match-names.mjs (3)
components/rosette_text_analytics/actions/extract-entities/extract-entities.mjs (1)
response(37-47)components/rosette_text_analytics/actions/translate-name/translate-name.mjs (1)
response(25-31)components/rosette_text_analytics/rosette_text_analytics.app.mjs (1)
response(27-27)
components/rosette_text_analytics/rosette_text_analytics.app.mjs (3)
components/rosette_text_analytics/actions/extract-entities/extract-entities.mjs (1)
response(37-47)components/rosette_text_analytics/actions/match-names/match-names.mjs (1)
response(25-35)components/rosette_text_analytics/actions/translate-name/translate-name.mjs (1)
response(25-31)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Lint Code Base
- GitHub Check: pnpm publish
- GitHub Check: Publish TypeScript components
- GitHub Check: Verify TypeScript components
🔇 Additional comments (2)
components/rosette_text_analytics/package.json (1)
3-3: Version bump looks good. Consider aligning component versions.
Package version is 0.1.0 while the new actions declare "0.0.1". If you want consistent semver across this package, bump the action metadata to 0.1.0 as well. If versions are intentionally decoupled, ignore.components/rosette_text_analytics/actions/match-names/match-names.mjs (1)
24-35: LGTM — correct payload shape for name similarity.
The request structure matches Rosette expectations (name1/name2 objects with text).
| const response = await this.app.translateName({ | ||
| $, | ||
| data: { | ||
| name: this.name, | ||
| targetLanguage: this.targetLanguage, | ||
| }, | ||
| }); | ||
| $.export("$summary", "Successfully translated name with " + response.confidence + " confidence"); | ||
| return response; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix request payload shape for Rosette translate API (wrap name in { text }).
Rosette APIs expect name fields as objects with a text property. Sending a string will likely 400. Also, make the summary robust to missing fields.
Apply this diff:
-    const response = await this.app.translateName({
-      $,
-      data: {
-        name: this.name,
-        targetLanguage: this.targetLanguage,
-      },
-    });
-    $.export("$summary", "Successfully translated name with " + response.confidence + " confidence");
-    return response;
+    const response = await this.app.translateName({
+      $,
+      data: {
+        name: { text: this.name },
+        targetLanguage: this.targetLanguage,
+      },
+    });
+    $.export(
+      "$summary",
+      `Translated ${this.name} to ${this.targetLanguage}` +
+        (response?.translatedName ? `: ${response.translatedName}` : "") +
+        (typeof response?.confidence === "number" ? ` (confidence: ${response.confidence})` : "")
+    );
+    return response;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const response = await this.app.translateName({ | |
| $, | |
| data: { | |
| name: this.name, | |
| targetLanguage: this.targetLanguage, | |
| }, | |
| }); | |
| $.export("$summary", "Successfully translated name with " + response.confidence + " confidence"); | |
| return response; | |
| const response = await this.app.translateName({ | |
| $, | |
| data: { | |
| name: { text: this.name }, | |
| targetLanguage: this.targetLanguage, | |
| }, | |
| }); | |
| $.export( | |
| "$summary", | |
| `Translated ${this.name} to ${this.targetLanguage}` + | |
| (response?.translatedName ? `: ${response.translatedName}` : "") + | |
| (typeof response?.confidence === "number" ? ` (confidence: ${response.confidence})` : "") | |
| ); | |
| return response; | 
🤖 Prompt for AI Agents
In components/rosette_text_analytics/actions/translate-name/translate-name.mjs
around lines 25 to 33, the payload sends name as a raw string but Rosette
expects name fields as an object with a text property; change the request data
to send name: { text: this.name } (keep targetLanguage unchanged), and make the
exported summary robust by handling missing response.confidence (e.g., default
to 'unknown' or similar) so the summary string never breaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @lcaresia, LGTM! Ready for QA!
WHY
Summary by CodeRabbit